﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Main_House : System.Web.UI.Page
{
    EncriptManager em = new EncriptManager();
    HouseDao hd = new HouseDao();
    DataTable dt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        string minmoney = txtminmoney.Text;
        string maxmoney = txtmaxmoney.Text;
        if (minmoney == "")
        {
            minmoney = "0";
        }
        if (maxmoney == "")
        {
            maxmoney = "99999";
        }
        dt = hd.getHouse(txtname.Text, minmoney, maxmoney, ddltype.SelectedValue, "0");
        if (dt == null)
        {
            string script = "<script>window.alert('对不起，没有相关楼盘信息！');</script>";
            Page.RegisterClientScriptBlock("", script);
            return;
        }
        if (dt.Rows.Count == 0)
        {
            string script = "<script>window.alert('对不起，没有相关楼盘信息！');</script>";
            Page.RegisterClientScriptBlock("", script);
            return;
        }
        dlhouse.DataSource = dt;
        dlhouse.DataBind();
        if (dt != null)
        {
            for (int i = 0; i < dlhouse.Items.Count; i++)
            {
                HiddenField Hiddenhid = dlhouse.Items[i].FindControl("Hiddenhid") as HiddenField;
                HyperLink Hlkhouse = dlhouse.Items[i].FindControl("Hlkhouse") as HyperLink;
                ImageButton Imbtnimage = dlhouse.Items[i].FindControl("Imbtnimage") as ImageButton;
                Label labhcost = dlhouse.Items[i].FindControl("labhcost") as Label;
                if (labhcost.Text == "0")
                {
                    labhcost.Text = "待定";
                }
                string hid = em.Encript(Hiddenhid.Value);
                Hlkhouse.NavigateUrl = "HouseInfo.aspx?hid=" + hid;
                Imbtnimage.PostBackUrl = "HouseInfo.aspx?hid=" + hid;
            }
        }
    }
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        BindData();
    }
}
